	var mapOptions;
	var projection; //proyeccion del mapa
	var displayProjection; //proyeccion del display
	var monitorButton = null;
	var tableroContainer = null;
	function loadlibraries(){
		document.getElementById('mapLoadingPanel').style.display = "block";
		dinamicIncludes_Map.includePreload();
	}

	function initialize() {
	  	//dinamicIncludes_Map.includeGeneral();
		cMapController = new cMapController();
		for(var n=0; n < cantMapas; n++){
			cMapController.addMap(new cMapa());
		}
	   	cMapController.setActive(0);
	  	cMapController.getMapActive().setCuentaSeguimiento(<?="'".$_GET['cuentaSelectSegui']."'"?>);
		cMapController.getMapActive().setSeleccionActual("-1");
		<? if (isset($_GET['cuentaSelectSelection'])) {?>
			cMapController.getMapActive().setSeleccionActual(<?="'".$_GET['cuentaSelectSelection']."'"?>);
		<? } ?>;
		MOVILES_VISIBLES = cMapController.getMapActive().getCuentaSeguimiento();
		<?php if (isset($_GET['movilesVISIBLES'])) {?>
			MOVILES_VISIBLES = <?="'".$_GET['movilesVISIBLES']."'"?> ;
		<?php } ?>;

		<?php 
			 if ($LOGIN->objetivoDB == 5){?>
				FIJOS_VISIBLES = <?="'".$_GET['cuentaSelectSegui']."'"?>
		<?php }
		?>

	  	$j("#iconoMapa").removeClass().addClass("icono_mapa");
	  	//AccordionMenu = new Spry.Widget.Accordion("AccordionMenu");

		cMapController.initMaps();
		mapServersList = vMAPAS_DISPONIBLES.split(",");
		//Controles OpenLayers
		for(var i=0;i<cantMapas;i++){
			cMapController.getMapById(i).initServers(i);
			cMapController.getMapById(i).initControls(i);
			cMapController.getMapById(i).setLonLat(new OpenLayers.LonLat(parseFloat(<?=$_GET['y']?>), parseFloat(<?=$_GET['x']?>)).transform(cMapController.getMapById(i).getDisplayProjection(), cMapController.getMapById(i).getProjection()));
			cMapController.getMapById(i).getMap().setCenter(cMapController.getMapById(i).getLonLat(), cMapController.getMapById(i).getZoomInitialMap());
		}
		for(var i=cantMapas;i<6;i++){
			$j("#map"+i).css("display","none");
		}

		dinamicIncludes_Map.setMessage('Cargando MOVILES...');
		CargarMisGruposVehiculos();
		if (LOGIN.objetivoDB == 5){
			CargarMisFijos();
		}
		//-------------------------------------
		vehiculosCargadosFlag  = true;
        RefreshForm();
		cMapController.initMapEvents();
		resizear();
		setInterval("AutoRefreshForm();", eval(<?= GMAP_MAPA_REFRESH_AVL ?>) * 1000);
		jscolor.init();
		initialMap(0);
		collapseMonitor();
    }

	 function handleMeasurements(event) {
            var geometry = event.geometry;
            var units = event.units;
            var order = event.order;
            var measure = event.measure;
            var out = "";
            if(order == 1) {
                out += "measure: " + measure.toFixed(3) + " " + units;
            } else {
                out += "measure: " + measure.toFixed(3) + " " + units + "<sup>2</" + "sup>";
            }
        }

	function unload(){
		//unloadBody();
	}

    function cleanAllStates(){
		if (LOGIN.PERMISOS[0])
			cleanEstadoNuevoGrupoVehiculos();
		if ((LOGIN.PERMISOS[7])&&(dinamicIncludes_Map.isMisPuntosInclude())){
    		cleanEstadoNuevoPunto();
	    	cleanEstadoModificarPunto();
    		cleanEstadoBuscarPunto();
    		cleanEstadoNuevoGrupo();
			}
		if ((LOGIN.PERMISOS[8])&&(dinamicIncludes_Map.isMisZonasInclude()))
			cMapController.getMapActive().cleanEstadoNuevaZona();
		if ((LOGIN.PERMISOS[9])&&(dinamicIncludes_Map.isLogisticaInclude())){
    		cleanEstadoNuevaRegla();
    		cleanEstadoAplicarRegla();
			}
    }
    function resizear() {
    	var theHeight = 0;
    	if (window.innerHeight) {
    		theHeight=window.innerHeight;
    	}
    	else if (document.documentElement && document.documentElement.clientHeight) {
    		theHeight=document.documentElement.clientHeight;
    	}
    	else if (document.body) {
    		theHeight=document.body.clientHeight;
    	}
    	if (theHeight > 590){
    		mapHeight = theHeight - 90;
    	}
    	else {
    		mapHeight = 500;
    	}

		document.getElementById('gMapMenuBar').style.height = mapHeight + "px";
		document.getElementById('mapLoadingPanel').style.height = theHeight + 'px';

	/*	if (dinamicIncludes_Map.isGeneralInclude()){
			for(var i=0;i<cantMapas;i++){
				if(vMaps[i].getMap() != null){
					vMaps[i].getMap().updateSize();
				}
				if (vMonitorButton[i] != null)
					vMonitorButton[i].redraw();
				if (vTableroContainer[i] != null)
					vTableroContainer[i].redraw();
			}
		}
	*/
    }


	function initializeGlobalVars(){
		LOGIN = jQuery.parseJSON('<?= $loginJSON ?>');
		mapCanvas = document.getElementById('map_canvas0');
		inPerUnit = OpenLayers.INCHES_PER_UNIT.m * metersPerUnit;
		OpenLayers.INCHES_PER_UNIT["dd"] = inPerUnit;
	    OpenLayers.INCHES_PER_UNIT["degrees"] = inPerUnit;
    	OpenLayers.DOTS_PER_INCH = 96;
		mapIcons = new MapIcons({
						misPuntos: LOGIN.PERMISOS[4]
					});
	}

	var _loadingBar = new ProgressBar({
								width: '150px',
     							container: 'mapLoadingBar'
     						  });

